<?php 
namespace Client\Controller;
use Think\Controller;
use Org\Net\Http;
use Org\BaiduREST\PushSDK;
class BaiduRESTController extends Controller{
	  public function BaiduRESTDemo(){
	  	import('Org.BaiduREST.PushSDK');
	  	$sdk = new \PushSDK();
	  	$channelId = '4058771429190913169';
	  	$message = array(
	  			'title'=>'Hi',
	  			'description'=>'王亚永你好'
	  	);
	  	$opts = array(
	  			'msg_type'=>1,
	  	);
	  	// 向目标设备发送一条消息
	  	$rs = $sdk -> pushMsgToSingleDevice($channelId, $message, $opts);
	  	
	  	// 判断返回值,当发送失败时, $rs的结果为false, 可以通过getError来获得错误信息.
	  	if($rs === false){
	  		print_r($sdk->getLastErrorCode());
	  		print_r($sdk->getLastErrorMsg());
	  	}else{
	  		// 将打印出消息的id,发送时间等相关信息.
	  		print_r($rs);
	  	}
	  	
	  	echo "done!";
	  } 

}
?>